﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using OnlineManagement.BLL;
namespace OnlineManagement.Web.pages
{
    public partial class HybridizationManagement : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           if(!Page.IsPostBack){
               HttpCookie cookie = new HttpCookie(OnlineManagement.Common.PubConstant.HoggeryIdCookieName, "1001");
               Response.Cookies.Add(cookie);
               if (Response.Cookies.Get(OnlineManagement.Common.PubConstant.HoggeryIdCookieName) != null)
               {
                   string hoggeryIdStr = Response.Cookies.Get(OnlineManagement.Common.PubConstant.HoggeryIdCookieName).Value;
                   int hoggeryId = 0;
                   if (int.TryParse(hoggeryIdStr, out hoggeryId))
                   {
                       BindDropDwonList(hoggeryId);
                   }
               }
           }
        }
        private void BindDropDwonList(int hoggeryID) {
            Sow bllSow = new Sow();
            DataSet ds=  bllSow.GetHybridizationSow(hoggeryID);
            if(ds!=null&&ds.Tables!=null&&ds.Tables.Count>0){
                ddlSowBitID.DataSource = ds;
                ddlSowBitID.DataTextField = "BitID";
                ddlSowBitID.DataValueField = "SowID";
                ddlSowBitID.DataBind();
            }
        }
    }
}